package com.wh.shiroswagger.result;

import lombok.Data;

/**
 * @Auther: HuiEr
 * @Date: 2020/3/5 21:20
 * @Description
 */
@Data
public class DataResult <T>{
    private int code;
    private String msg;
    private T data;

    public  DataResult(int code,String msg){
        this.code=code;
        this.msg=msg;
    }

    public  DataResult(int code,String msg,T data){
        this.code=code;
        this.msg=msg;
        this.data=data;
    }

    public DataResult(AbstractResponse abstractResponse){
        this.code=abstractResponse.getCode();
        this.msg=abstractResponse.getMsg();
    }

    public DataResult(AbstractResponse abstractResponse,T data){
        this.code=abstractResponse.getCode();
        this.msg=abstractResponse.getMsg();
        this.data=data;
    }

    public static <T> DataResult success(AbstractResponse abstractResponse,T data){
        return new DataResult(abstractResponse,data);
    }

    public static DataResult exceptionOccur(AbstractResponse abstractResponse){
        return new DataResult(abstractResponse);
    }
    public static  DataResult exceptionOccur(int code,String msg){
        return new DataResult(code,msg);
    }

}
